package com.srb.core.controller.api;

import com.srb.common.result.R;
import com.srb.core.pojo.entity.Dict;
import com.srb.core.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author dapeng
 * @since 2021-08-08
 */
@Api(tags = {"数据字典"})
@Slf4j
@RestController
@RequestMapping("/api/core/dict")
//@CrossOrigin
public class ApiDictController {

    @Autowired
    private DictService dictService;

    @ApiOperation(value = "根据dictCode获取下级节点")
    @GetMapping(value = {"/findByDictCode/{dictCode}"})
    public R findByDictCode(@ApiParam(value = "字节编码",required = true)@PathVariable(value = "dictCode") String dictCode){
        List<Dict> list = dictService.findByDictCode(dictCode);
        return R.ok().data("list",list);
    }
}
